import { request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(obj: ResultType) {
  if (obj.result?.resultCode === '000000') {
    return obj.data
  }
  return obj
}

/** 系统管理 start */
//查询企业能效指标配置管理列表
export const queryNxzbpzQyManagerList = (params?: any) =>
  request.get('/nxzbpz-qy/queryNxzbpzQyManagerList', { params }).then((res: any) => adapter(res))

//分页查询园区信息
export const queryPageYqxx = (params?: any) =>
request.get('/yqxx/query/page/yqxx', { params }).then((res: any) => adapter(res))

//新增或修改园区信息
export const yqxxInsertOrUpdate = (data?: any) =>
  request.post('/yqxx/insertOrUpdate', data).then((res: any) => adapter(res))

/** ----- 企业对象管理 ----- */
//分页查询企业信息
export const qyxx = (params?: any) =>
  request.get('/qyxx/query/page/qyxx', { params }).then((res: any) => adapter(res))

//根据id查询企业信息
export const queryQyxxInfo = (params?: any) =>
  request.get('/qyxx/queryQyxxInfo', { params }).then((res: any) => adapter(res))

//新增企业信息
export const qyxxInsertOrUpdate = (data?: any) =>
  request.post('/qyxx/insertOrUpdate', data).then((res: any) => adapter(res))

/** ----- 监测点位管理 ----- */
//监测点位管理列表
export const queryJcdwManager = (params?: any) =>
  request.get('/jcdw/queryJcdwManager', { params }).then((res: any) => adapter(res))

//新增或修改监测点位
export const jcdwInsertOrUpdate = (data?: any) =>
  request.post('/jcdw/insertOrUpdate', data).then((res: any) => adapter(res))

//新增或修改用能项目信息
export const nxzbpzQyInsertOrUpdate = (data?: any) =>
  request.post('/nxzbpz-qy/insertOrUpdate', data).then((res: any) => adapter(res))

//查询园区能效指标配置管理列表
export const queryNxzbpzYqManagerList = (params?: any) =>
  request.get('/nxzbpz-yq/queryNxzbpzYqManagerList', { params }).then((res: any) => adapter(res))

//新增或修改园区能效指标配置表
export const nxzbpzYqInsertOrUpdate = (data?: any) =>
  request.post('/nxzbpz-yq/insertOrUpdate', data).then((res: any) => adapter(res))

//查询能源折标系数列表
export const nyzbxsQueryNyzbxs = (params?: any) =>
  request.get('/nyzbxs/query/nyzbxs', { params }).then((res: any) => adapter(res))

//新增或修改能源折标系数
export const nyzbxsInsertOrUpdate = (data?: any) =>
  request.post('/nyzbxs/insertOrUpdate', data).then((res: any) => adapter(res))
